<template>
<!-- <criteria-paged :model="model" v-ref:paged> -->
<div>
  <div novalidate class="form-inline auto" partial>
    <div class="form-group">
    时间:
    <input type="text" class="form-control" v-model="model.f_date" placeholder="如 2016-04"
    condition="f_date='{}%'">
    </div>
    <!-- <button class="btn btn-default" @click="confirm()">查询</button> -->
    <div class="form-group">
         <button type="button" class="btn btn-success width-80" @click="confirm()">查询</button>
    </div>
    <button class="btn btn-default" @click="$back()">返回</button>
  </div>

<data-grid :model="model" partial='list' v-ref:grid>
  <template partial='head'>
    <tr>
      <th> </th>
      <th> </th>
      <th> </th>
      <th> </th>
      <th> </th>
      <th> </th>
      <th> </th>
      <th> </th>
      <th> </th>
      <th> </th>
    </tr>
  </template>
  <template partial='body'>
    <tr>
      <th>员工ID</th>
      <td>{{row.f_user_id}}</td>

        <th>员工姓名</th>
        <td>{{row.f_user_name}}</td>

      <th>缺勤</th>
      <td>{{row.f_absentteeism}}</td>

      <th>迟到</th>
      <td>{{row.late}}</td>

      <th>早退</th>
      <td>{{row.f_leave_early}}</td>
    </tr>
  </template>
</data-grid>
</div>

<!-- </criteria-paged> -->

</template>
<script>
import co from 'co'
// import UserfileChange from './UserfileChange'
// import MessageBox from '../..src/plugins/MessageBox'
let checkingin = function * (self) {
  console.log('safDsz')
  console.log(self.f.parentid)
  let state = yield self.$post('rs/sql/月考勤', {data: {parentid: self.f.parentid, f_user_id: self.f.f_userid, f_date: self.model.f_date}}, {resolveMsg: null, rejectMsg: null})
  console.log('state', state)
  self.model.rows = state.data
}
let search = function * (self) {
  console.log('safDsz')
  console.log(self.f.parentid)
  let state = yield self.$post('rs/sql/月考勤', {data: { parentid: self.f.parentid, f_user_id: self.f.f_userid, f_date: self.model.f_date }}, {resolveMsg: null, rejectMsg: null})
  console.log('state', state)
  self.model.rows = state.data
}

export default {
  title: '汇总',
  data () {
    return {
      model: {
        rows: [],
        f_date: this.toStandardMonthString()
      }
    }
  },
  props: ['f', 'row'],
  methods: {
    checker (row) {
      this.$goto('userfile-change', {functions: row})
    },
    confirm () {
      let gen = search(this)
      return co(gen)
    },
    toStandardMonthString () {
      let dt = new Date()
      let month = dt.getMonth() + 1
      return dt.getFullYear() + '-' + (month < 10 ? '0' + month : month)
    }
  },
  ready () {
    let gen = checkingin(this)
    return co(gen)
  }
}
</script>




<!-- <template>

<div>
  <div novalidate class="form-inline auto" partial>

    <div class="form-group">
    日期:
    <input type="text" class="form-control" v-model="model.f_date"
    condition="f_date='{}'">
    </div>
    <button class="btn btn-default" @click="confirm()">查询</button>
    <button @click="$back()" class="btn btn-success">返&nbsp;&nbsp;&nbsp;回</button>



</div>

<data-grid :model="model" partial='list' v-ref:grid>
  <template partial='body'>
    <tr>
      <th>员工ID</th>
      <td>{{row.f_user_id}}</td>
    </tr>
    <tr>
        <th>员工姓名</th>
        <td>{{row.f_user_name}}</td>
    </tr>
    <tr>
      <th>缺勤</th>
      <td>{{row.f_absentteeism}}</td>
    </tr>
    <tr>
      <th>迟到</th>
      <td>{{row.f_late}}</td>
    </tr>
    <tr>
      <th>早退</th>
      <td>{{row.f_leave_early}}</td>
    </tr>
  </template>

</data-grid>
</div>


</template>

<script>
import co from 'co'
// import UserfileChange from './UserfileChange'
// import MessageBox from '../..src/plugins/MessageBox'
let checkingin = function * (self) {
  console.log('safDsz')
  console.log(self.f.parentid)
  let state = yield self.$post('rs/sql/汇总', {data: {parentid: self.f.parentid, f_user_id: self.row.f_user_id}})
  console.log('state', state)
  self.model.rows = state.data
}
let search = function * (self) {
  console.log('safDsz')
  console.log(self.f.parentid)
  let state = yield self.$post('rs/sql/月汇总', {data: {f_date: self.f.parentid, f_user_id: self.row.f_user_id, date: self.model.f_date}})
  console.log('state', state)
  self.model.rows = state.data
}

export default {
  title: '汇总',
  data () {
    return {
      model: {
        rows: []
      }
    }
  },
  props: ['f'],
  methods: {
    confirm () {
      let gen = search(this)
      return co(gen)
    }
  },
  ready () {
    let gen = checkingin(this)
    return co(gen)
  }
}
</script> -->
